﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Selection Sort</title>
    <link href="styles/js-console.css" rel="stylesheet" />
</head>
<body>
     <div id="js-console"></div>
	<script src="scripts/js-console.js"></script>
	<script>
	    var min = Number.MIN_VALUE;
	    var arr = [2, 35, 3, 2, 1, 5, 7, 6, -5, 24];
	    jsConsole.writeLine("Before selection sort: ");
	    for (var k = 0; k < arr.length; k++) {
	        jsConsole.write(arr[k] + " ");
	    }
	    for (var i = 0; i < arr.length; i++) {
	        min = i;
	        for (var j = i + 1; j < arr.length; j++) {
	            if (arr[min] > arr[j]) {
	                min = j;
	            }
	        }
	        if (min != i)
	        {
	            var temp = arr[i];
	            arr[i] = arr[min];
	            arr[min] = temp;
	        }
	    }
	    jsConsole.writeLine();
	    jsConsole.writeLine("After selection sort: ")
	    for (var i = 0; i < arr.length; i++) {
	        jsConsole.write(arr[i] + " ");
	    }
    </script>
</body>
</html>
